home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / tar.gnu / sprite / RCS / tar.h,v < prev    next >
Encoding:
Text File  |  1992-03-29  |  11.2 KB  |  438 lines

  1. head     1.5;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.5
  10. date     92.03.28.17.33.02;  author kupfer;  state Exp;
  11. branches ;
  12. next     1.4;
  13.  
  14. 1.4
  15. date     92.03.05.21.10.57;  author rab;  state Exp;
  16. branches ;
  17. next     1.3;
  18.  
  19. 1.3
  20. date     90.10.27.17.50.33;  author rab;  state Exp;
  21. branches ;
  22. next     1.2;
  23.  
  24. 1.2
  25. date     90.06.28.15.35.18;  author rab;  state Exp;
  26. branches ;
  27. next     1.1;
  28.  
  29. 1.1
  30. date     90.03.21.22.14.51;  author rab;  state Exp;
  31. branches ;
  32. next     ;
  33.  
  34.  
  35. desc
  36. @@
  37.  
  38.  
  39. 1.5
  40. log
  41. @Add comments.  Fixes for long names.
  42. @
  43. text
  44. @/*
  45.  
  46.     Copyright (C) 1988 Free Software Foundation
  47.  
  48. GNU tar is distributed in the hope that it will be useful, but WITHOUT ANY
  49. WARRANTY.  No author or distributor accepts responsibility to anyone
  50. for the consequences of using it or for whether it serves any
  51. particular purpose or works at all, unless he says so in writing.
  52. Refer to the GNU tar General Public License for full details.
  53.  
  54. Everyone is granted permission to copy, modify and redistribute GNU tar,
  55. but only under the conditions described in the GNU tar General Public
  56. License.  A copy of this license is supposed to have been given to you
  57. along with GNU tar so you can know your rights and responsibilities.  It
  58. should be in a file named COPYING.  Among other things, the copyright
  59. notice and this notice must be preserved on all copies.
  60.  
  61. In other words, go ahead and share GNU tar, but don't try to stop
  62. anyone else from sharing it farther.  Help stamp out software hoarding!
  63. */
  64.  
  65. /*
  66.  * Header file for tar (tape archive) program.
  67.  *
  68.  * @@(#)tar.h 1.24 87/11/06
  69.  *
  70.  * Created 25 August 1985 by John Gilmore, ihnp4!hoptoad!gnu.
  71.  */
  72.  
  73. #ifdef sprite
  74. #define DEFBLOCKING 8
  75. #define ALLOW_NO_RECURSE
  76. #define ALLOW_LONG_NAMES
  77. #endif
  78.  
  79. /*
  80.  * Kludge for handling systems that can't cope with multiple
  81.  * external definitions of a variable.  In ONE routine (tar.c),
  82.  * we #define TAR_EXTERN to null; here, we set it to "extern" if
  83.  * it is not already set.
  84.  */
  85. #ifndef TAR_EXTERN
  86. #define TAR_EXTERN extern
  87. #endif
  88.  
  89. #ifdef USG
  90. typedef int size_t;
  91. #endif
  92.  
  93. /*
  94.  * Header block on tape.
  95.  *
  96.  * I'm going to use traditional DP naming conventions here.
  97.  * A "block" is a big chunk of stuff that we do I/O on.
  98.  * A "record" is a piece of info that we care about.
  99.  * Typically many "record"s fit into a "block".
  100.  */
  101. #define    RECORDSIZE    512
  102. #define    NAMSIZ        100
  103. #define    TUNMLEN        32
  104. #define    TGNMLEN        32
  105. #define SPARSE_EXT_HDR  21
  106. #define SPARSE_IN_HDR    4
  107.  
  108. struct sparse {
  109.     char offset[12];
  110.     char numbytes[12];
  111. };
  112.  
  113. struct sp_array {
  114.     int offset;
  115.     int numbytes;
  116. };
  117.  
  118. #define HDR_MAGIC 0xa3
  119.  
  120. union record {
  121.     char        charptr[RECORDSIZE];
  122.     struct header {
  123.         char    name[NAMSIZ];
  124.         char    mode[8];
  125.         char    uid[8];
  126.         char    gid[8];
  127.         char    size[12];
  128.         char    mtime[12];
  129.         char    chksum[8];
  130.         char    linkflag;
  131.         char    linkname[NAMSIZ];
  132.         char    magic[8];
  133.         char    uname[TUNMLEN];
  134.         char    gname[TGNMLEN];
  135.         char    devmajor[8];
  136.         char    devminor[8];
  137.         /* these following fields were added by JF for gnu */
  138.         /* and are NOT standard */
  139.         char    atime[12];
  140.         char    ctime[12];
  141.         char    offset[12];
  142.         char    longnames[4];
  143.         struct    sparse sp[SPARSE_IN_HDR];
  144.         char    isextended;
  145.         char    realsize[12];         /* true size of the sparse file */
  146.         unsigned char hdr_magic;
  147. /*        char    ending_blanks[12];*/ /* number of nulls at the
  148.                            end of the file, if any */
  149.     } header;
  150.     struct extended_header {
  151.         unsigned char xh_isextended; /* non-zero -> continued in
  152.                           * next record */
  153.         unsigned char xh_type;
  154.         unsigned char xh_magic;
  155.         union {
  156.             struct sparse _xh_sp[21];
  157.             /* 
  158.              * The buffer is only 508 characters so that the string 
  159.              * stored in it will be null-terminated
  160.              */
  161.             char _xh_namebuf[508];
  162.         } u;
  163.     } ext_hdr;
  164. };
  165.  
  166. #define xh_sp           u._xh_sp
  167. #define xh_namebuf      u._xh_namebuf
  168.  
  169. /* 
  170.  * Non-ASCII magic number to distinguish a header with GNU extensions from 
  171.  * a Posix header with a prefixed name.  (A Posix header would have either 
  172.  * an ASCII character or a null.) (XXX what about 8-bit character sets?)
  173.  */
  174. #define XH_MAGIC        0xab
  175.  
  176. /* Flags telling what types of extended header records follow. */
  177. #define XH_FILENAME     1
  178. #define XH_LINKNAME     2
  179. #define XH_SPARSE_FILE  4
  180.  
  181. /* The checksum field is filled with this while the checksum is computed. */
  182. #define    CHKBLANKS    "        "    /* 8 blanks, no null */
  183.  
  184. /* The magic field is filled with this if uname and gname are valid. */
  185. #define    TMAGIC        "ustar  "    /* 7 chars and a null */
  186.  
  187. /* The linkflag defines the type of file */
  188. #define    LF_OLDNORMAL    '\0'        /* Normal disk file, Unix compat */
  189. #define    LF_NORMAL    '0'        /* Normal disk file */
  190. #define    LF_LINK        '1'        /* Link to previously dumped file */
  191. #define    LF_SYMLINK    '2'        /* Symbolic link */
  192. #define    LF_CHR        '3'        /* Character special file */
  193. #define    LF_BLK        '4'        /* Block special file */
  194. #define    LF_DIR        '5'        /* Directory */
  195. #define    LF_FIFO        '6'        /* FIFO special file */
  196. #define    LF_CONTIG    '7'        /* Contiguous file */
  197. /* Further link types may be defined later. */
  198. #ifdef sprite
  199. #define LF_RMTLINK    '8'        /* Remote link, kind of symbolic link */
  200. #define LF_PSEUDODEV    '9'        /* Pseudo-device (for server process) */
  201. #endif /* sprite */
  202.  
  203. #define LF_DUMPDIR    'D'        /* This is a dir entry that contains
  204.                        the names of files that were in
  205.                        the dir at the time the dump
  206.                        was made */
  207. #define LF_MULTIVOL    'M'        /* This is the continuation
  208.                        of a file that began on another
  209.                        volume */
  210. #define LF_SPARSE    'S'        /* This is for sparse files */
  211. #define LF_VOLHDR    'V'        /* This file is a tape/volume header */
  212.                     /* Ignore it on extraction */
  213.  
  214. /*
  215.  * Exit codes from the "tar" program
  216.  */
  217. #define    EX_SUCCESS    0        /* success! */
  218. #define    EX_ARGSBAD    1        /* invalid args */
  219. #define    EX_BADFILE    2        /* invalid filename */
  220. #define    EX_BADARCH    3        /* bad archive */
  221. #define    EX_SYSTEM    4        /* system gave unexpected error */
  222.  
  223.  
  224. /*
  225.  * Global variables
  226.  */
  227. TAR_EXTERN union record    *ar_block;    /* Start of block of archive */
  228. TAR_EXTERN union record    *ar_record;    /* Current record of archive */
  229. TAR_EXTERN union record    *ar_last;    /* Last+1 record of archive block */
  230. TAR_EXTERN char        ar_reading;    /* 0 writing, !0 reading archive */
  231. TAR_EXTERN int        blocking;    /* Size of each block, in records */
  232. TAR_EXTERN int        blocksize;    /* Size of each block, in bytes */
  233. TAR_EXTERN char        *ar_file;    /* File containing archive */
  234. TAR_EXTERN char        *info_script;    /* Script to run at end of each tape change */
  235. TAR_EXTERN char        *name_file;    /* File containing names to work on */
  236. TAR_EXTERN char        *tar;        /* Name of this program */
  237. TAR_EXTERN struct sp_array *sparsearray;/* Pointer to the start of the scratch space */
  238. TAR_EXTERN int        sp_array_size;    /* Initial size of the sparsearray */
  239. TAR_EXTERN char        *current_filename; /* file name for current header */
  240. TAR_EXTERN char        *current_linkname; /* link name for current header */
  241.  
  242. /*
  243.  * Flags from the command line
  244.  */
  245. TAR_EXTERN int cmd_mode;
  246. #define CMD_NONE    0
  247. #define CMD_CAT        1        /* -A */
  248. #define CMD_CREATE    2        /* -c */
  249. #define CMD_DIFF    3        /* -d */
  250. #define CMD_APPEND    4        /* -r */
  251. #define CMD_LIST    5        /* -t */
  252. #define CMD_UPDATE    6        /* -u */
  253. #define CMD_EXTRACT    7        /* -x */
  254. #define CMD_DELETE    8        /* -D */
  255.  
  256.                     /* -[0-9][lmh] */
  257.             /* CMD_CAT       -A */
  258.                     /* -b */
  259. TAR_EXTERN int    f_reblock;        /* -B */
  260.             /* CMD_CREATE       -c */
  261.                     /* -C */
  262.             /* CMD_DIFF       -d */
  263. /* TAR_EXTERN char    f_dironly;    /* -D */
  264. TAR_EXTERN int    f_debug;            /* -e */
  265.                     /* -f */
  266. TAR_EXTERN int    f_run_script_at_end;    /* -F */
  267. TAR_EXTERN int     f_gnudump;        /* -G */
  268. TAR_EXTERN int    f_follow_links;        /* -h */
  269. TAR_EXTERN int    f_ignorez;        /* -i */
  270.             /* CMD_DELETE       -J */
  271. TAR_EXTERN int    f_keep;            /* -k */
  272. TAR_EXTERN int    f_startfile;        /* -K */
  273. TAR_EXTERN int    f_local_filesys;    /* -l */
  274. TAR_EXTERN int    f_long_names;        /* -L */
  275. TAR_EXTERN int    f_modified;        /* -m */
  276. TAR_EXTERN int     f_multivol;        /* -M */
  277. TAR_EXTERN int  f_no_recurse;           /* -n */
  278. TAR_EXTERN int    f_new_files;        /* -N */
  279. TAR_EXTERN int    f_oldarch;        /* -o */
  280. TAR_EXTERN int  f_exstdout;        /* -O */
  281. TAR_EXTERN int    f_use_protection;    /* -p */
  282. TAR_EXTERN int  f_absolute_paths;    /* -P */
  283. TAR_EXTERN int    f_sayblock;        /* -R */
  284. TAR_EXTERN int    f_sorted_names;        /* -s */
  285. TAR_EXTERN int    f_sparse_files;        /* -S  ... JK */
  286. TAR_EXTERN int    f_namefile;        /* -T */
  287.             /* CMD_UPDATE       -u */
  288. TAR_EXTERN int    f_verbose;        /* -v */
  289. TAR_EXTERN char *f_volhdr;        /* -V */
  290. TAR_EXTERN int  f_confirm;        /* -w */
  291. TAR_EXTERN int  f_verify;        /* -W */
  292.             /* CMD_EXTRACT     -x */
  293. TAR_EXTERN int  f_exclude;        /* -X */
  294. TAR_EXTERN int     f_compress;        /* -z */
  295.                     /* -Z */
  296.  
  297. /*
  298.  * We now default to Unix Standard format rather than 4.2BSD tar format.
  299.  * The code can actually produce all three:
  300.  *    f_standard    ANSI standard
  301.  *    f_oldarch    V7
  302.  *    neither        4.2BSD
  303.  * but we don't bother, since 4.2BSD can read ANSI standard format anyway.
  304.  * The only advantage to the "neither" option is that we can cmp our
  305.  * output to the output of 4.2BSD tar, for debugging.
  306.  */
  307. #define        f_standard        (!f_oldarch)
  308.  
  309. /*
  310.  * Structure for keeping track of filenames and lists thereof.
  311.  */
  312. struct name {
  313.     struct name    *next;
  314.     short        length;        /* cached strlen(name) */
  315.     char        found;        /* A matching file has been found */
  316.     char        firstch;    /* First char is literally matched */
  317.     char        regexp;        /* This name is a regexp, not literal */
  318.     char        *change_dir;    /* JF set with the -C option */
  319.     char        *dir_contents;    /* JF for f_gnudump */
  320.     char        name[NAMSIZ+1];
  321. };
  322.  
  323. TAR_EXTERN struct name    *namelist;    /* Points to first name in list */
  324. TAR_EXTERN struct name    *namelast;    /* Points to last name in list */
  325.  
  326. TAR_EXTERN int        archive;    /* File descriptor for archive file */
  327. TAR_EXTERN int        errors;        /* # of files in error */
  328.  
  329. /*
  330.  *
  331.  * Due to the next struct declaration, each routine that includes
  332.  * "tar.h" must also include <sys/types.h>.  I tried to make it automatic,
  333.  * but System V has no defines in <sys/types.h>, so there is no way of
  334.  * knowing when it has been included.  In addition, it cannot be included
  335.  * twice, but must be included exactly once.  Argghh!
  336.  *
  337.  * Thanks, typedef.  Thanks, USG.
  338.  */
  339. struct link {
  340.     struct link    *next;
  341.     dev_t        dev;
  342.     ino_t        ino;
  343.     short        linkcount;
  344.     char        name[NAMSIZ+1];
  345. };
  346.  
  347. TAR_EXTERN struct link    *linklist;    /* Points to first link in list */
  348.  
  349.  
  350. /*
  351.  * Error recovery stuff
  352.  */
  353. TAR_EXTERN char        read_error_flag;
  354.  
  355.  
  356. /*
  357.  * Declarations of functions available to the world.
  358.  */
  359. union record *findrec();
  360. void userec();
  361. union record *endofrecs();
  362. void anno();
  363. char *extended_header_type_name();
  364. void get_names();
  365.  
  366. /* Do not prototype these for BSD--see port.c [DOPRNT_MSG].  */
  367. #if defined(__STDC__) && (!defined(BSD42) || defined(sprite))
  368. void msg(char *, ...);
  369. void msg_perror(char *, ...);
  370. #else
  371. void msg();
  372. void msg_perror();
  373. #endif
  374. /* #define     annorec(stream, msg)    anno(stream, msg, 0)    /* Cur rec */
  375. /* #define    annofile(stream, msg)    anno(stream, msg, 1)    /* Saved rec */
  376. @
  377.  
  378.  
  379. 1.4
  380. log
  381. @Add magic number to file header (Mike checking in for Bob).
  382. @
  383. text
  384. @a33 1
  385. #define LONG_FILENAME_TEMPLATE   "/tmp/dump.name_too_long.XXXXXX"
  386. d108 2
  387. a109 1
  388.         unsigned char xh_isextended;
  389. d114 4
  390. d125 6
  391. d132 2
  392. d196 2
  393. d231 1
  394. d320 2
  395. @
  396.  
  397.  
  398. 1.3
  399. log
  400. @Added debug flag.
  401. @
  402. text
  403. @d76 1
  404. d104 1
  405. @
  406.  
  407.  
  408. 1.2
  409. log
  410. @Added support for long filenames and long symbolic linkes.
  411. @
  412. text
  413. @d205 1
  414. @
  415.  
  416.  
  417. 1.1
  418. log
  419. @Initial revision
  420. @
  421. text
  422. @d30 7
  423. d102 2
  424. a103 2
  425.         char    realsize[12];        /* true size of the sparse file */
  426. /*        char    ending_blanks[12];*/    /* number of nulls at the
  427. d107 7
  428. a113 2
  429.         struct sparse sp[21];
  430.         char isextended;
  431. d117 7
  432. d141 4
  433. d216 1
  434. d304 1
  435. a304 1
  436. #if defined(__STDC__) && !defined(BSD42)
  437. @
  438.